import 'package:flutter/material.dart';

class OverflowBoxExample extends StatefulWidget {
  const OverflowBoxExample({Key? key}) : super(key: key);

  @override
  State<OverflowBoxExample> createState() => _OverflowBoxExampleState();
}

class _OverflowBoxExampleState extends State<OverflowBoxExample> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('OverflowBoxExample'),
      ),
      body: SingleChildScrollView(
        scrollDirection: Axis.vertical,
        child: Column(
          children: [
            Container(
              color: Colors.pink,
              width: 200,
              height: 200,
              padding: EdgeInsets.all(10.0),
              child: OverflowBox(
                alignment: Alignment.bottomLeft,
                maxHeight: 200,
                maxWidth: 200,
                child: Container(
                  color: Colors.amber[900],
                  width: 50,
                  height: 50,
                ),
              ),
            ),
            Container(
              width: 50,
              height: 50,
              color: Colors.orange,
              alignment: Alignment.topRight,
              child: OverflowBox(
                minWidth: 60,
                maxWidth: 60,
                minHeight: 60,
                maxHeight: 60,
                alignment: Alignment.bottomRight,
                child: Text(
                  '自制',
                  style: TextStyle(
                    backgroundColor: Colors.white,
                  ),
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
